home *** CD-ROM | disk | FTP | other *** search
- /*
- * The original copyright owners of the accompanying source code files have
- * agreed to place such code into the public domain. Accordingly, anyone
- * who receives or obtains a copy of such source code is freely entitled to
- * reproduce, use and otherwise exploit such code (including the right to
- * make derivative works), at his/her own risk and expense, without any
- * obligation or liability to the original copyright owners.
- *
- * We would appreciate (but do not require) that the following message be
- * included in any derivative works:
- *
- * "Portions of this program were developed by Peter Broadwell, Rob Myers
- * and Robin Schaufler while working in Silicon Valley."
- *
- * The accompanying source code files and related documentation materials
- * are distributed on an "AS IS" basis, without any warranties or
- * guarantees of any kind. All implied warranties, including the implied
- * warranties of merchantability and of fitness for any particular purpose,
- * are expressly disclaimed.
- */
- #include "gl.h"
- #include "geom.h"
- #include "selectors.h"
- #include "class.h"
- #include "classIds.h"
- #include "mbox.h"
- #include "behavior.h"
- #include "individual.h"
- #include "doers.h"
-
- extern class behaveClass;
- extern char *wigglerBub;
- extern char *feederBub;
- extern char *colorizerBub;
- extern char *femaleBub;
- extern char *maleBub;
-
- extern char *wiggle();
- extern char *advanceTo();
- extern char *swimTo();
- extern char *influ();
- extern char *altercolor();
- extern char *exportcolor();
- extern char *altershape();
- extern char *freeMetaVars();
- extern char *feed();
- extern char *wideneye();
- extern char *editFeeder();
- extern char *editMale();
- extern char *editFemale();
- extern char *editWiggler();
- extern char *editColorizer();
-
- fcnTable wiggleTable[] = {
- DOIT, wiggle, /* wiggle my head and tail*/
- ADDPANEL, editWiggler,
- EOTABLE,
- };
-
- class wigglerClass = {
- &behaveClass,
- wiggleTable,
- sizeof(wiggler),
- WIGGLER,
- };
-
- wigglerVars wigglerVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* wiggler */
- 0, /* angle */
- 90, /* magnitude */
- 0, /* wiggleClock */
- };
-
- wiggler wigglerTemplate = {
- /* inst */
- &wigglerClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(wigglerVars), /* size of template for */
- (char *)&wigglerVarTemplate, /* instance variables */
- (char *)&wigglerBub, /* symbolic bubble */
- /* wiggler */
- 10, /* offsetFactor */
- };
-
- fcnTable swerveTable[] = {
- DOIT, swimTo, /* advance to next spot along my path */
- EOTABLE,
- };
-
- class swerverClass = {
- &behaveClass,
- swerveTable,
- sizeof(behavior),
- SWERVER,
- };
-
- swerverVars swerverVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* swerver */
- {80,80,80}, /* stake */
- };
-
- behavior swerverTemplate = {
- /* inst */
- &swerverClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(swerverVars), /* size of template for */
- (char *)&swerverVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- fcnTable circleTable[] = {
- DOIT, advanceTo, /* advance to next spot along my circle */
- EOTABLE,
- };
-
- class circlerClass = {
- &behaveClass,
- circleTable,
- sizeof(behavior),
- CIRCLER,
- };
-
- circlerVars circlerVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* circler */
- {100,100,1000}, /* stake */
- 10000, /* tether */
- 0, /* circleClock */
- 0, /* circleIncr */
- };
-
- behavior circlerTemplate = {
- /* inst */
- &circlerClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(circlerVars), /* size of template for */
- (char *)&circlerVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- fcnTable chameleonTable[] = {
- DOIT, altercolor, /* listen to colors from outer space */
- EOTABLE,
- };
-
- class chameleonClass = {
- &behaveClass,
- chameleonTable,
- sizeof(behavior),
- CHAMELEON,
- };
-
- chameleonVars chameleonVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* chameleon */
- FALSE, /* inited */
- FALSE, /* influenced */
- {0,0,0}, /* nativeColor */
- {0,0,0}, /* importColor */
- };
-
- behavior chameleonTemplate = {
- /* inst */
- &chameleonClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(chameleonVars), /* size of template for */
- (char *)&chameleonVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- fcnTable colorizerTable[] = {
- DOIT, exportcolor, /* export color influence to neighbors */
- ADDPANEL, editColorizer,
- EOTABLE,
- };
-
- class colorizerClass = {
- &behaveClass,
- colorizerTable,
- sizeof(behavior),
- COLORIZER,
- };
-
- colorizerVars colorizerVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* colorizer */
- {255,255,0}, /* exportColor */
- };
-
- behavior colorizerTemplate = {
- /* inst */
- &colorizerClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(colorizerVars), /* size of template for */
- (char *)&colorizerVarTemplate, /* instance variables */
- (char *)&colorizerBub, /* symbolic bubble */
- };
-
- extern char *advance();
-
- fcnTable advancerTable[] = {
- DOIT, advance, /* advance by velocity by acceleration */
- EOTABLE,
- };
-
- class advancerClass = {
- &behaveClass,
- advancerTable,
- sizeof(behavior),
- ADVANCER,
- };
-
- behavior advancerTemplate = {
- /* inst */
- &advancerClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(subscr), /* size of template for */
- NULL, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- extern char *dieAtSurface();
-
- fcnTable surfDieTable[] = {
- DOIT, dieAtSurface, /* die if height is at or above surface */
- EOTABLE,
- };
-
- class surfDieClass = {
- &behaveClass,
- surfDieTable,
- sizeof(surfaceDie),
- SURFACEDIE,
- };
-
- surfaceDie surfDieTemplate = {
- /* inst */
- &surfDieClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(subscr), /* size of template for */
- NULL, /* instance variables */
- NULL, /* symbolic bubble */
- /* surfaceDie */
- 5000, /* surface */
- };
-
- extern char *expandScale();
-
- fcnTable expanderTable[] = {
- DOIT, expandScale, /* increase in size up to a limit */
- EOTABLE,
- };
-
- class expanderClass = {
- &behaveClass,
- expanderTable,
- sizeof(behavior),
- EXPANDER,
- };
-
- expanderVars expanderVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* expander */
- 1.0, /* scaleMax */
- 1.3, /* scaleIncr */
- };
-
- behavior expanderTemplate = {
- /* inst */
- &expanderClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(expanderVars), /* size of template for */
- (char *)&expanderVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- extern char *fadeOut();
-
- fcnTable faderTable[] = {
- DOIT, fadeOut, /* fade out of existence */
- EOTABLE,
- };
-
- class faderClass = {
- &behaveClass,
- faderTable,
- sizeof(behavior),
- FADER,
- };
-
- faderVars faderVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* fader */
- 16, /* lifeSpan in tics */
- 16, /* age in tics */
- };
-
- behavior faderTemplate = {
- /* inst */
- &faderClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(faderVars), /* size of template for */
- (char *)&faderVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- extern char *trailGhosts();
-
- fcnTable trailGhostTable[] = {
- DOIT, trailGhosts, /* fade out of existence */
- EOTABLE,
- };
-
- class trailGhostClass = {
- &behaveClass,
- trailGhostTable,
- sizeof(behavior),
- TRAIL_GHOSTS,
- };
-
- trailGhostVars trailGhostVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* fader */
- 4, /* frequency in tics */
- 0, /* tic mod frequency */
- };
-
- behavior trailGhostTemplate = {
- /* inst */
- &trailGhostClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(trailGhostVars), /* size of template for */
- (char *)&trailGhostVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- extern char *lay(), *fertilize();
-
- fcnTable femaleTable[] = {
- DOIT, lay, /* if a male is nearby, lay eggs */
- ADDPANEL, editFemale,
- EOTABLE,
- };
-
- class femaleClass = {
- &behaveClass,
- femaleTable,
- sizeof(behavior),
- FEMALE,
- };
-
- femaleVars femaleVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* femaleVars */
- 2, /* n_girls */
- 1, /* n_boys */
- 4, /* max_population */
- NULL, /* mate */
- };
-
- behavior femaleTemplate = {
- /* inst */
- &femaleClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(femaleVars), /* size of template for */
- (char *)&femaleVarTemplate, /* instance variables */
- (char *)&femaleBub, /* symbolic bubble */
- };
-
- fcnTable maleTable[] = {
- DOIT, fertilize, /* if a female is nearby, fertilize eggs */
- ADDPANEL, editMale,
- EOTABLE,
- };
-
- class maleClass = {
- &behaveClass,
- maleTable,
- sizeof(behavior),
- MALE,
- };
-
- maleVars maleVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* maleVars */
- -4, /* interest */
- 30, /* rate */
- 0, /* tics */
- -4, /* min_int */
- 6, /* max_int */
- 2.0, /* eyescale */
- 0, /* flags */
- };
-
- behavior maleTemplate = {
- /* inst */
- &maleClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(maleVars), /* size of template for */
- (char *)&maleVarTemplate, /* instance variables */
- (char *)&maleBub, /* symbolic bubble */
- };
-
- fcnTable metamorphTable[] = {
- DOIT, altershape, /* when alarm goes off, change shape */
- EOTABLE,
- };
-
- class metamorphClass = {
- &behaveClass,
- metamorphTable,
- sizeof(behavior),
- METAMORPH,
- };
-
- metamorphVars metamorphVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* metamorph */
- 0, /* clock */
- 100, /* alarm */
- NULL, /* embryo */
- };
-
- behavior metamorphTemplate = {
- /* inst */
- &metamorphClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(metamorphVars), /* size of template for */
- (char *)&metamorphVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-
- fcnTable dinnerTable[] = {
- DOIT, feed, /* when alarm goes off, change shape */
- ADDPANEL, editFeeder, /* edit vars associated with feeder */
- EOTABLE,
- };
-
- class feederClass = {
- &behaveClass,
- dinnerTable,
- sizeof(behavior),
- FEEDER,
- };
-
- feederVars feederVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* metamorph */
- -6, /* interest */
- 100, /* rate */
- 0, /* tics */
- -6, /* min_int */
- 6, /* max_int */
- FALSE, /* cannibal */
- 50.0, /* bubscale */
- };
-
- behavior feederTemplate = {
- /* inst */
- &feederClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(feederVars), /* size of template for */
- (char *)&feederVarTemplate, /* instance variables */
- (char *)&feederBub, /* symbolic bubble */
- };
-
- fcnTable wideyeTable[] = {
- DOIT, wideneye, /* listen to colors from outer space */
- EOTABLE,
- };
-
- class wideyeClass = {
- &behaveClass,
- wideyeTable,
- sizeof(behavior),
- WIDEYE,
- };
-
- wideyeVars wideyeVarTemplate = {
- /* subscr */
- NULL, /* next subscriber */
- NULL, /* member pointer */
- /* wideye */
- FALSE, /* inited */
- FALSE, /* influenced */
- 2.0, /* scalefactor */
- };
-
- behavior wideyeTemplate = {
- /* inst */
- &wideyeClass, /* myClass pointer */
- NULL, /* classFunctions */
- 0, /* nFunctions */
- /* mailbox */
- NULL, /* subscribers */
- NULL, /* subscribedTo */
- /* behavior */
- sizeof(wideyeVars), /* size of template for */
- (char *)&wideyeVarTemplate, /* instance variables */
- NULL, /* symbolic bubble */
- };
-